<?php
$this->breadcrumbs=array(
	tt('FAQ'),
);

$this->h1 = tt('FAQ');
?>

<?php
echo CHtml::htmlButton(
		tt('Create FAQ'), 
		array(
			'class'=>'button grey', 
			'onclick'=>'document.location.href="'.Yii::app()->createAbsoluteUrl(
					"/faq/admin/default/create").'"'
			)
);

$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'faq-grid',
	'itemsCssClass'=>'item-class',
	'pagerCssClass'=>'pager-class',
	'cssFile'=>Yii::app()->theme->baseUrl.'/css/tables.css',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		array(
			'name' => 'active',
			'type' => 'raw',
			'value' => 'Yii::app()->controller->returnStatusHtml($data, "faq-grid", 0, 0)',
			'htmlOptions' => array('class'=>'grid-status-column'),
			'filter' => false,
			'sortable' => false,
		),

		array(
			'name' => 'question_'.Yii::app()->language,
			'sortable' => false,
		),

		array(
			'name' => 'answer_'.Yii::app()->language,
			'type' => 'raw',
			'value' => 'truncateText($data->answer_'.Yii::app()->language.')',
			'sortable' => false,
		),
		
		array(
			'class'=>'CButtonColumn',
			'template'=>'{up}{down}{view}{update}{delete}',
			'deleteConfirmation' => tt('Are you sure you want to delete this question?'),
			'viewButtonUrl' => "Yii::app()->createUrl('/faq/admin/default/view', array('id' => \$data->id))",
			'htmlOptions' => array('class'=>'button-column'),
			'buttons' => array(
				'up' => array(
					'label' => tt('Move menu item up'),
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/bullet_arrow_up.png',
					'url'=>'Yii::app()->createUrl("/faq/admin/default/move", array("id"=>$data->id, "direction" => "up"))',
					'visible' => '$data->sorter > 1',
				),
				'down' => array(
					'label' => tt('Move menu item down'),
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/bullet_arrow_down.png',
					'url'=>'Yii::app()->createUrl("/faq/admin/default/move", array("id"=>$data->id, "direction" => "down"))',
					'visible' => '$data->sorter < "'.$maxSorter.'"',
				),
				'view' => array(
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/icon_view.png',
				),
				'update' => array(
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/icon_edit.png',
				),
				'delete' => array(
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/icon_delete.png',
//					'visible' => '$data->id != 1',
				),
			),
		),
	),
));
?>

